home *** CD-ROM | disk | FTP | other *** search
Wrap
/* ** $VER: WhirlGIF.ieb 1.2, IE Arexx script ** Image Engineer Batch Processing script ** Copyright © by Patrik M Nydensten ** 25/1 1997 Stockholm/Sweden ** ** Merges gif pictures to a gif animation, using the program WhirlGif 2.01. ** WhirlGIF is assumed to be within the search path. WhirlGIF can be ** downloaded from AmiNet (AmiNet:gfx/conv/whirlgif201.lha). */ options results signal on error parse arg input command input = upper(strip(input)) address 'IMAGEENGINEER' select /* Required batch script commands */ when input = 'INFO' then return get_info() when input = 'CONFIG' then return get_config(command) when input = 'PROCESS' then return process_image(command) otherwise do 'REQUEST' '"Failure in call to batch script!"' '" Quit "' return '<ERROR>' end end exit 0 /* Required "Get_info" procedure ------------------------------------ */ /* S = SECONDARY, A = ALPHA, 1 = Single file, 2 = Multiple files */ get_info: back = 'OK F' return back /* Required "Get_config" procedure ---------------------------------- */ get_config: parse arg '"'command'"' loops=99999 ; t_value=15 if command ~= '' then parse var command '#'disp_method '#'loops t_value '#'timingQ 'IE_TO_FRONT' form = 'FORM "WhirlGif" " OK | Cancel "' if command = '' then do form = form||' CYCLE,"Disposal method:","None - no disposal specified (normal)|'||, 'Back - clear to background (may flicker)|Prev - ues previous frame data|'||, 'Not - do not dispose (image overlay)",0', ' INTEGER,"Loops",0,99999,99999,SLIDER' end form = form||' INTEGER,"Frame timing (1/100 s)",1,10000,'t_value',SLIDER' if command = '' then do form = form||' CHECKBOX,"Ask for new new frame timing for all frames?",1' form parse var result ok disp_method loops t_value timingQ . if ok = 0 then return '<ERROR>' end else do form parse var result ok t_value . if ok = 0 then return '<ERROR>' disp_method = 'none' loops = 'none' timingQ = 'none' end back = '#'disp_method '#'loops t_value '#'timingQ return back /* Required "Process_image" procedure ------------------------------- */ process_image: parse arg '"'src_image'"' '"'dst_image'"' '"'options'"' '"'frame':'num_frames'"' parse var options '#'disp_method '#'loops t_value '#'timingQ . /* first frame only -------------------------------- */ if frame = 1 then do if strip(getclip(wgif_tval)) = '' then call setclip(wgif_tval,strip(t_value)) if ~open('df','t:WG.df','W') then return '<ERROR>' call writeln('df','** WhirlGIF.ieb datafile **') call close('df') end /* all frames -------------------------------------- */ if ~open('df','t:WG.df','A') then return '<ERROR>' t_value = strip(t_value) if timingQ = 1 then do 'REQUEST' '"Use frame timing value:' t_value d2c(10)||, 'for frame' frame 'of' num_frames '?"' '" Yes, use' t_value '| No, use' getclip(wgif_tval) '| No, set new "' if result = 0 then do if datatype(getclip(wgif_tval),'N') then t_value = getclip(wgif_tval) 'GET_NUMBER' '"Set frame timing value for frame' frame 'of' num_frames'"' '1 10000' '" OK "' t_value 'SLIDER' t_value = result call setclip(wgif_tval,t_value) end if result = 2 then if datatype(getclip(wgif_tval),'N') then t_value = getclip(wgif_tval) end call writeln('df',t_value) call writeln('df',src_image) call close('df') /* last frame only -------------------------------- */ if frame = num_frames then do if exists('t:WG.df') then do if ~open('df','t:WG.df','R') then return '<ERROR>' end else return '<ERROR>' call readln('df') if ~open('exes','t:WG.script','W') then return '<ERROR>' select when disp_method = 0 then disp_method = 'none' when disp_method = 1 then disp_method = 'back' when disp_method = 2 then disp_method = 'prev' when disp_method = 3 then disp_method = 'not' otherwise return '<ERROR>' end call writeln('exes','Cd' '"'get_path(dst_image)'"') call writech('exes','Whirlgif -v -o "'get_file(get_base(dst_image))||, '" -disp' disp_method '-loop' loops) com_string = '' ; prev_tval = -1 ; ifiles = 0 do while ~eof('df') read_tval = readln('df') if eof('df') then leave if read_tval ~= prev_tval then do ifiles = ifiles + 1 call writech('exes',' -time' read_tval '-i t:WG.i'ifiles) if ~open('ifile','t:WG.i'ifiles,'W') then return '<ERROR>' end else if ~open('ifile','t:WG.i'ifiles,'A') then return '<ERROR>' call writeln('ifile',readln('df')) call close('ifile') prev_tval = read_tval end /* while */ call close('exes') call close('df') 'WB_TO_FRONT' address 'COMMAND' 'execute t:WG.script' if RC~=0 then 'REQUEST' '"WhirlGIF returned error code while processing your'd2c(10)||, 'gif images. Please see output window on Workbench."', '" OK "' 'IE_TO_FRONT' end /* last frame */ back = 'OK' return back /* Internal procedures ---------------------------------------------- */ get_base: parse arg get_base_in if lastpos('.',get_base_in) ~= 0 then get_base_back = substr(get_base_in,1,lastpos('.',get_base_in)-1) else get_base_back = get_base_in return get_base_back get_path: parse arg get_path_in if lastpos('/',get_path_in) ~= 0 then get_path_back = substr(get_path_in,1,lastpos('/',get_path_in)) else if lastpos(':',get_path_in) ~= 0 then get_path_back = substr(get_path_in,1,lastpos(':',get_path_in)) else get_path_back = '' return get_path_back get_file: parse arg get_file_in if lastpos('/',get_file_in) ~= 0 then get_file_back = substr(get_file_in,1+lastpos('/',get_file_in)) else if lastpos(':',get_file_in) ~= 0 then get_file_back = substr(get_file_in,1+lastpos(':',get_file_in)) else get_file_back = get_file_in return get_file_back /*******************************************************************/ /* This is where control goes when an error code is returned by IE */ /* It puts up a message saying what happened and on which line */ /*******************************************************************/ error: if RC=5 then do IE_TO_FRONT LAST_ERROR 'REQUEST "'||RESULT||'"' end else do IE_TO_FRONT LAST_ERROR 'REQUEST "Error detected!!!'||D2C(10)||'Image Engineer error message is as follows'||D2C(10)||result||D2C(10)||'Script failed on line '||SIGL||'"' 'Doh!' end return '<ERROR>'